﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <script language="javascript"> 
var url = "ajax/ajaxFile.aspx"; 
var binary; 
var filename; 
var mytext; 

function upload() { 
   filename = document.getElementById('myfile').value; 
   mytext = document.getElementById('mytext').value; 
   document.getElementById('ajaxbutton').disabled = true; 

   // request local file read permission 
   try { 
       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
   } catch (e) { 
       alert("Permission to read file was denied."); 
   } 
    
   // open the local file 
   var file = Components.classes["@mozilla.org/file/local;1"] 
       .createInstance(Components.interfaces.nsILocalFile); 
   file.initWithPath( filename );         
   stream = Components.classes["@mozilla.org/network/file-input-stream;1"] 
       .createInstance(Components.interfaces.nsIFileInputStream); 
   stream.init(file,    0x01, 00004, null); 
   var bstream =  Components.classes["@mozilla.org/network/buffered-input-stream;1"] 
       .getService(); 
   bstream.QueryInterface(Components.interfaces.nsIBufferedInputStream); 
   bstream.init(stream, 1000); 
   bstream.QueryInterface(Components.interfaces.nsIInputStream); 
   binary = Components.classes["@mozilla.org/binaryinputstream;1"] 
       .createInstance(Components.interfaces.nsIBinaryInputStream); 
   binary.setInputStream (stream); 

   // start AJAX file upload in 1 second 
   window.setTimeout("ajax_upload()", 1000); 
} 

function ajax_upload() { 
   // request more permissions 
   try { 
       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
   } catch (e) { 
       alert("Permission to read file was denied."); 
   } 

   http_request = false; 
   http_request = new XMLHttpRequest(); 
   if (!http_request) { 
       alert('Cannot create XMLHTTP instance'); 
       return false; 
   } 

   // prepare the MIME POST data 
   var boundaryString = 'capitano'; 
   var boundary = '--' + boundaryString; 
   var requestbody = boundary + '\n' 
   + 'Content-Disposition: form-data; name="mytext"' + '\n' 
   + '\n' 
   + mytext + '\n' 
   + '\n' 
   + boundary + '\n' 
   + 'Content-Disposition: form-data; name="myfile"; filename="' 
       + filename + '"' + '\n' 
   + 'Content-Type: application/octet-stream' + '\n' 
   + '\n' 
   + escape(binary.readBytes(binary.available())) 
   + '\n' 
   + boundary; 

   document.getElementById('sizespan').innerHTML = 
       "requestbody.length=" + requestbody.length; 
    
   // do the AJAX request 
   http_request.onreadystatechange = requestdone; 
   http_request.open('POST', url, true); 
   http_request.setRequestHeader("Content-type", "multipart/form-data; \ 
       boundary=\"" + boundaryString + "\""); 
   http_request.setRequestHeader("Connection", "close"); 
   http_request.setRequestHeader("Content-length", requestbody.length); 
   http_request.send(requestbody); 

} 

function requestdone() { 
   if (http_request.readyState == 4) { 
       if (http_request.status == 200) { 
           result = http_request.responseText; 
           document.getElementById('myspan').innerHTML = result;             
       } else { 
           alert('There was a problem with the request.'); 
       } 
       document.getElementById('ajaxbutton').disabled = false; 
   } 
} 

</script> 
  <script type="text/javascript" language="javascript">
      function StartUpload(sender, args) {
          var filename = args.get_fileName();
          if (filename != "") {
              // code to get File Extension..
              var arr1 = new Array;
              arr1 = filename.split("\\");
              var len = arr1.length;
              var img1 = arr1[len - 1];
              var filext = img1.substring(img1.lastIndexOf(".") + 1);


              // Checking Extension
              if (filext == "jpg" || filext == "jpeg" || filext == "gif" || filext == "bmp")
                  return true;
              else {
                  alert("Invalid File Format Selected");
                  var fu = document.getElementById("AsyncFileUpload1");
                  document.getElementById("AsyncFileUpload1").innerHTML = fu.innerHTML;
                  return false;
              }
          }
      }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id='upload'>
        <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </ajaxToolkit:ToolkitScriptManager>
      <%--<ajaxToolkit:AsyncFileUpload ID="AsyncFileUpload1" runat="server" 
            UploaderStyle="Modern"  />--%>
    
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <asp:FileUpload ID="FileUpload1" runat="server" />
        <asp:RegularExpressionValidator 
                     id="RegularExpressionValidator1" runat="server" 
                     ErrorMessage="Chỉ chấp nhận file .mp4 " 
                     ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.rar|.zip)$" 
                    ControlToValidate="FileUpload1"></asp:RegularExpressionValidator>
        <br />
    
        <p class="MsoNormal" 
            style="color: rgb(0, 0, 0); font-family: Arial, Verdana, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; margin-top: 0.5pt; margin-right: 0in; margin-bottom: 0.5pt; margin-left: 0in; ">
            <b><span style="font-size: 11pt; ">Pan tilt CCD Wirless<span 
                class="Apple-converted-space">&nbsp;</span></span><span 
                style="font-size: 10.5pt; "><span>&nbsp;</span>IP Camera hồng ngoại</span></b></p>
        <p class="MsoNormal" 
            style="color: rgb(0, 0, 0); font-family: Arial, Verdana, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; margin-top: 0.5pt; margin-right: 0in; margin-bottom: 0.5pt; margin-left: 0in; ">
            <span style="font-size: 10.5pt; ">- 1/3 Sony CCD , 420 Tivi Lines</span></p>
        <p class="MsoNormal" 
            style="color: rgb(0, 0, 0); font-family: Arial, Verdana, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; margin-top: 0.5pt; margin-right: 0in; margin-bottom: 0.5pt; margin-left: 0in; ">
            <span style="font-size: 10.5pt; ">- Hỗ trợ âm thanh</span></p>
        <p class="MsoNormal" 
            style="color: rgb(0, 0, 0); font-family: Arial, Verdana, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; margin-top: 0.5pt; margin-right: 0in; margin-bottom: 0.5pt; margin-left: 0in; ">
            <span style="font-size: 10.5pt; ">- Pan 220<sup>0</sup>, Tilt : 90<sup>0</sup></span></p>
        <p class="MsoNormal" 
            style="color: rgb(0, 0, 0); font-family: Arial, Verdana, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; margin-top: 0.5pt; margin-right: 0in; margin-bottom: 0.5pt; margin-left: 3pt; ">
            <span style="font-size: 10.5pt; ">- Khung hình: 640 x 480 pixel . Tốc độ hiển 
            thị /ghi hình:25fps PAL</span></p>
        <p class="MsoNormal" 
            style="color: rgb(0, 0, 0); font-family: Arial, Verdana, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; margin-top: 0.5pt; margin-right: 0in; margin-bottom: 0.5pt; margin-left: 3pt; ">
            <span style="font-size: 10.5pt; ">- Led hồng ngọai : 10pcs / 3~10m</span></p>
        <p class="MsoNormal" 
            style="color: rgb(0, 0, 0); font-family: Arial, Verdana, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; margin-top: 0.5pt; margin-right: 0in; margin-bottom: 0.5pt; margin-left: 3pt; ">
            <span style="font-size: 10.5pt; ">- Network : 10/100<span 
                class="Apple-converted-space">&nbsp;</span><span class="style11"><span>Mbps 
            Ethernet<span class="Apple-converted-space">&nbsp;</span></span></span>(RJ-45) .</span></p>
        <p class="MsoNormal" 
            style="color: rgb(0, 0, 0); font-family: Arial, Verdana, sans-serif; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; margin-top: 0.5pt; margin-right: 0in; margin-bottom: 0.5pt; margin-left: 3pt; ">
            <span style="font-size: 10.5pt; ">- Network protocol: HTTP, TCP/IP, DHCP, DDNS, 
            NTP. Hỗ trợ : Internet Explorer .</span></p>
        <span style="color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: 10.5pt; font-family: 'Times New Roman', serif; ">
        <span>&nbsp;</span>- Nguồn : DC 5V - 1000mA - Cỡ:120x135 .</span><br />
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
      <asp:Panel ID="Panel2" runat="server">
        adad
    </asp:Panel>
    <ajaxToolkit:BalloonPopupExtender ID="PopupControlExtender2" runat="server" TargetControlID="Button1"
        BalloonPopupControlID="Panel2" Position="BottomRight" BalloonStyle="Cloud" BalloonSize="Small"
        UseShadow="false" DisplayOnClick="true" DisplayOnFocus="true" />
   </div>
    </form>
 
</body>
</html>
